#include"string.h"


namespace basic_siring
{
	void test1()
	{
		basic_siring::string str("hello world");

		for (auto& e : str)
		{
			cout << e << " ";
		}
		cout << endl;

		const basic_siring::string str1 = "xxxxxxxx";
		for (size_t i = 0; i < str1.size(); i++)
		{
			cout << str1[i] << " ";
		}
		cout << endl;
	}

	void test2()
	{
		basic_siring::string str("hello world");
		str.push_back('x');
		str.append("yyyyy");
		cout << str.c_str() << endl;
	}

	void test3()
	{
		basic_siring::string str("hello world");
		str.push_back('x');
		str.append("yyyyy");

		str.insert(0, 'z');
		cout << str.c_str() << endl;
	}

	void test4()
	{
		basic_siring::string str("hello world");
		cout << str.c_str() << endl;

		str.insert(0, " the");
		cout << str.c_str() << endl;
	}

	void test_string3()
	{
		basic_siring::string s1("hello world");
		cout << s1.c_str() << endl;

		s1.insert(6, 'x');
		cout << s1.c_str() << endl;

		s1.insert(0, 'x');
		cout << s1.c_str() << endl;

		basic_siring::string s2("hello world");
		cout << s2.c_str() << endl;

		s2.insert(6, "yyy");
		cout << s2.c_str() << endl;

		s2.insert(0, "yyy");
		cout << s2.c_str() << endl;

		basic_siring::string s3("hello world");
		cout << s3.c_str() << endl;
		//s3.erase(6, 10);
		s3.erase(6);
		cout << s3.c_str() << endl;

		basic_siring::string s4("hello world");
		cout << s4.c_str() << endl;
		s4.erase(6, 3);
		cout << s4.c_str() << endl;
	}


	void test5()
	{
		basic_siring::string str("hello world");
		cout << str.c_str() << endl;

		str.erase(1);
		cout << str.c_str() << endl;
	}
	void test_string4()
	{
		basic_siring::string s1("hello world");
		cout << s1.find('o') << endl;
		cout << s1.find("wor") << endl;
	}

	void test6()
	{
		basic_siring::string s1("hello world");
		basic_siring::string s2(s1);

		s1[0] = 'x';
		cout << s1.c_str() << endl;
		cout << s2.c_str() << endl;

		basic_siring::string s3("yyyy");
		s1 = s3;
		cout << s1.c_str() << endl;
		cout << s3.c_str() << endl;

		basic_siring::string s4("zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz");
		s1 = s4;
		cout << s1.c_str() << endl;
		cout << s4.c_str() << endl;

		s1 = s1;
		cout << s1.c_str() << endl;
		cout << s3.c_str() << endl;
	}

	void test7()
	{
		string str("hello world");
		cin >> str;
		cout << str << endl;
	}
}


int main()
{
	basic_siring::test6();

	return 0;
}